package com.lethelh.lambda;

public class LambdaSample {
    public static void main(String[] args) {
        //1.标准Lambda使用方式
        MathOperator add = (Integer a, Integer b) -> {
            System.out.println("加法运算");
            return a+b+0f;
        };
        System.out.println(add.operate(5, 3));
        //2.Lambda允许忽略参数类型
        MathOperator sub = (a, b) -> {
            System.out.println("减法运算");
            return a-b+0f;
        };
        System.out.println(sub.operate(5,3));
        //3.单行实现代码可以省略大括号和return；参数有且只有一个可以省略参数外的小括号
        MathOperator multi = (a, b) -> a*b+0f;
        System.out.println("乘法运算");
        System.out.println(multi.operate(5,3));
        MathOperator div = (a, b) -> {
            System.out.println("除法运算");
            return a/b+0f;
        };
        System.out.println(div.operate(6,3));
    }
}
